package com.ruoyi.monitor.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.monitor.domain.MonitorAlarmImages;
import com.ruoyi.monitor.service.IMonitorAlarmImagesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监控基本图片Controller
 * 
 * @author wym
 * @date 2024-03-01
 */
@RestController
@RequestMapping("/monitor/alarmimages")
public class MonitorAlarmImagesController extends BaseController
{
    @Autowired
    private IMonitorAlarmImagesService monitorAlarmImagesService;

    /**
     * 查询监控基本图片列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:alarmimages:list')")
    @GetMapping("/list")
    public TableDataInfo list(MonitorAlarmImages monitorAlarmImages)
    {
        startPage();
        List<MonitorAlarmImages> list = monitorAlarmImagesService.selectMonitorAlarmImagesList(monitorAlarmImages);
        return getDataTable(list);
    }

    /**
     * 导出监控基本图片列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:alarmimages:export')")
    @Log(title = "监控基本图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MonitorAlarmImages monitorAlarmImages)
    {
        List<MonitorAlarmImages> list = monitorAlarmImagesService.selectMonitorAlarmImagesList(monitorAlarmImages);
        ExcelUtil<MonitorAlarmImages> util = new ExcelUtil<MonitorAlarmImages>(MonitorAlarmImages.class);
        util.exportExcel(response, list, "监控基本图片数据");
    }

    /**
     * 获取监控基本图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('monitor:alarmimages:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(monitorAlarmImagesService.selectMonitorAlarmImagesById(id));
    }

    /**
     * 新增监控基本图片
     */
    @PreAuthorize("@ss.hasPermi('monitor:alarmimages:add')")
    @Log(title = "监控基本图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MonitorAlarmImages monitorAlarmImages)
    {
        return toAjax(monitorAlarmImagesService.insertMonitorAlarmImages(monitorAlarmImages));
    }

    /**
     * 修改监控基本图片
     */
    @PreAuthorize("@ss.hasPermi('monitor:alarmimages:edit')")
    @Log(title = "监控基本图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MonitorAlarmImages monitorAlarmImages)
    {
        return toAjax(monitorAlarmImagesService.updateMonitorAlarmImages(monitorAlarmImages));
    }

    /**
     * 删除监控基本图片
     */
    @PreAuthorize("@ss.hasPermi('monitor:alarmimages:remove')")
    @Log(title = "监控基本图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(monitorAlarmImagesService.deleteMonitorAlarmImagesByIds(ids));
    }
}
